//
//  YDOACatRechargeVC.swift
//  YDOAProduct
//
//  Created by YDWY on 2017/6/13.
//  Copyright © 2017年 Allen. All rights reserved.
//

import UIKit

class YDOACatRechargeVC: UIViewController {

    @IBOutlet weak var kahaoBtn: UIButton!
    @IBOutlet weak var jingeTf: UITextField!
    @IBOutlet weak var youhaoBtn: UIButton!
    @IBOutlet weak var priceTF: UITextField!
    @IBOutlet weak var updataBtn: UIButton!

    @IBOutlet weak var imgView: UIImageView!
    @IBOutlet weak var imgHeigth: NSLayoutConstraint!
    @IBOutlet weak var viewHeight: NSLayoutConstraint!
    
    var btntype : Bool = false // 用来判断点的是哪个按钮
    
    var flag : Bool = true
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "汽车加油申请详情"
       
        setupUI()
        
        
        
        
        
    }

    
    
    
    fileprivate func setupUI(){
    
        kahaoBtn.layer.borderColor = UIColor.lightGray.cgColor
        kahaoBtn.layer.borderWidth = 1
        youhaoBtn.layer.borderColor = UIColor.lightGray.cgColor
        youhaoBtn.layer.borderWidth = 1
        
        
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    //选择油卡
    @IBAction func youkaBtnclick(_ sender: UIButton) {
        
        let popmenu = YMPopMenu(frame: self.view.bounds, dataSource:[
                ["item":"15312313513","id":"1"],
                ["item":"4515131321531","id":"2"],
                ["item":"18720933632","id":"3"],
                ["item":"15002151736","id":"4"],
            ])
        
        
        view.addSubview(popmenu)
        weak var weakSelf = self
        popmenu.callBack = {(id :String , title : String) in
            weakSelf?.kahaoBtn.setTitle(title, for: .normal)
            YMLog.log(item: "\(title) ==== \(id)")
        }
    }
    
    //选择油号
    @IBAction func youhaoBtnclick(_ sender: UIButton) {
        
        let popmenu = YMPopMenu(frame: self.view.bounds, dataSource:[
            ["item":"111111111","id":"1"],
            ["item":"222222222","id":"2"],
            ["item":"333333333","id":"3"],
            ["item":"444444444","id":"4"],
            ])
        
        
        view.addSubview(popmenu)
        weak var weakSelf = self
        popmenu.callBack = {(id :String , title : String) in
            weakSelf?.youhaoBtn.setTitle(title, for: .normal)
            YMLog.log(item: "\(title) ==== \(id)")
        }
    }
  
    //上传凭证
    @IBAction func updataBtnclick(_ sender: Any) {
        
        let imgPickerVC  = YMImgPickerVC()
        imgPickerVC.modalPresentationStyle = .overCurrentContext //模态视图的展现形式
        imgPickerVC.view.backgroundColor = UIColor(white: 0.3, alpha: 0.7) //视图的背景颜色
        
       weak var weakSelf = self
        imgPickerVC.callbackWithImg = {(imgData:Data) in
           
            weakSelf?.imgHeigth.constant = 100
            weakSelf?.imgView.image = UIImage(data: imgData)
            weakSelf?.viewHeight.constant = 400
        }
        
        self.present(imgPickerVC, animated: true, completion: {
            
        })

    }
    
    //确认按钮点击
    @IBAction func sureBtnclick(_ sender: Any) {
        
         navigationController?.pushViewController(YDOASucceedVC(), animated: true)
    }
    
    deinit {
        CommonMenuView.clearMenu()
    }
    
}
